<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .content{
            display: none;
            width: 200px;
            height: 200px;
            border:2px solid red;
        }
        .active {
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <button class="active">111</button>
        <button>222</button>
        <button>333</button>
        <div class="content" style="display: block;">111</div>
        <div class="content">222</div>
        <div class="content">333</div>
    </div>
    <script>
        var btn = document.getElementsByTagName('button');
        var div = document.getElementsByClassName('content');
        for(var i = 0; i < btn.length; i++) {
            (function (n) {
                btn[n].onclick = function () {
                // 去掉原本的类样式
                for(var j = 0; j < btn.length; j++) {
                    btn[j].className = "";
                    div[j].style.display = "none";
                }
                // 同时激活需要的类样式
                btn[n].className = "active";
                div[n].style.display = "block";
            }
            }(i))
        }
    
    </script>
</body>
</html>